<%@ tag language="java" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%><%-- 使用该组件请在header.tag和footer.tag中引入ueditor类库 --%>
<%@ attribute name="id" type="java.lang.String" required="true" description="组件的ID"%>
<%@ attribute name="name" type="java.lang.String" required="true" description="文本名称（name）"%>
<%@ attribute name="value" type="java.lang.String" required="true" description="文本域值（value）"%>
<%@ attribute name="readonly" type="java.lang.Boolean" required="false" description="编辑器是否是只读"%>
<%@ attribute name="maxlength" type="java.lang.String" required="false" description="编辑器最大输入数"%>
<%@ attribute name="height" type="java.lang.String" required="false" description="编辑器高度"%>
<%@ attribute name="simpleToolbars" type="java.lang.Boolean" required="false" description="使用简单toolbars"%>
<%--
	调用实例：
	<sys:ueditor id="content" name="contentText" value="${message.contentText}" maxlength="2000" height="130" simpleToolbars="true"/>
	
	空值验证：
	$("#inputForm").validate({
		submitHandler: function(form){
			// 验证content内容是否为空
			if (!contentUE.hasContents()){
           		contentUE.focus();
            	showMessage('请填写正文内容！', '警告', 'warning');
                return false;
            }
            // 以下为提交表单及后续代码
            ajaxSubmitForm($(form), function(data){
			}, "json");
        }
	});
--%>
<textarea id="${id}" name="${name}" rows="4" style="display:none;"></textarea>
<script type="text/plain" id="${id}UE" style="width:100%;height:${not empty height ? height : 200}px;">${value}</script>
<script type="text/javascript">
var ${id}UE;
$(function() {
	${id}UE = UE.getEditor('${id}UE', {
		<c:if test="${not empty maxlength}">maximumWords: ${maxlength}, </c:if>
		<c:if test="${not empty simpleToolbars}">toolbars: 
			[['fullscreen', 'source', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 
			  'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 
			  'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|', 'simpleupload', 'insertimage', 
			  'emotion', 'scrawl', 'insertvideo', 'music', 'attachment']], </c:if>
		readonly: ${not empty readonly ? readonly : false}
	});
	${id}UE.updateContent = function(){<%-- ${id}UE.updateContent(); //  更新编辑器内容  --%>
		$('#${id}').val("<!--HTML-->" + (${id}UE.getContent()).replace('<!--HTML-->',''));
	};
	${id}UE.addListener('contentChange', function(){
		${id}UE.updateContent();
	});
});
</script>